import allure
import pytest
from selenium import webdriver;
from selenium.webdriver.common.by import By;
import time;
from setting_floor import sele_setting;
from logs_floor import logs_obj;
logs = logs_obj.get_diy_log_obj()

browser_obj = sele_setting.get_browser("chrome");
time.sleep(5)

@allure.epic("积分管理系统")
@allure.feature("登录")

@pytest.mark.parametrize("username,userpwd",[("admin","12345"),("adminss","admin"),("adsdsd","sdsdsd"),("admin","admin")])
def test_integralsystem_login(username,userpwd):
    browser_obj.get("http://127.0.0.1:8080/jk_integralsystem/login.jsp");
    time.sleep(3);
    browser_obj.find_element(by=By.ID,value="uname").send_keys(username);
    time.sleep(3)
    browser_obj.find_element(by=By.ID,value="upwd").send_keys(userpwd);
    time.sleep(3);
    browser_obj.find_element(by=By.CLASS_NAME,value="logingBut").click();
    time.sleep(3);
    login_alert_content = browser_obj.switch_to.alert.text
    if login_alert_content == "":
        logs.info("登录场景测试通过")
    else:
        logs.error("登录失败场景")
@allure.epic("积分管理系统")
@allure.feature("添加学生")
def test_integralsystem_addstu():
    frame1 = browser_obj.find_element(by=By.XPATH,value="/html/frameset/frameset/frame[1]");
    time.sleep(3)
    #进入页面内嵌框架
    browser_obj.switch_to.frame(frame1);
    time.sleep(3)
    browser_obj.find_element(by=By.LINK_TEXT,value="积分管理").click();
    time.sleep(3);
    #退出页面内嵌框架
    browser_obj.switch_to.default_content();
    time.sleep(3)
    time.sleep(3)
    frame2 = browser_obj.find_element(by=By.XPATH,value="/html/frameset/frameset/frame[2]");
    browser_obj.switch_to.frame(frame2);
    time.sleep(3);
    time.sleep(3);
    browser_obj.find_element(by=By.XPATH,value="/html/body/div[1]/center/div/div/form/input[1]").click()


